import request from '@/utils/request';

// 销售订单列表
export function orderList(data) {
    return request({
        url: '/system/salesOrder/list',
        method: 'get',
        params: data
    })
}

// 新建销售订单
export function orderAdd(data) {
    return request({
        url: '/system/salesOrder/add',
        method: 'post',
        data: data
    })
}

// 编辑销售订单
export function orderEdit(data) {
    return request({
        url: '/system/salesOrder/edit',
        method: 'post',
        data: data
    })
}

// 删除
export function orderDelete(id) {
    return request({
        url: '/system/salesOrder/remove?id=' + id,
        method: 'post'
    })
}

// 删除商品
export function delProduct(id) {
    return request({
        url: '/system/salesOrderDetail/remove?id=' + id,
        method: 'post'
    })
}

// 查询销售订单详细信息
export function orderDetail(id) {
    return request({
        url: '/system/salesOrder/getInfo?id=' + id,
        method: 'get'
    })
}

// 审核/反审核
export function orderApprove(id, status, approveStatus, oldApproveStatus, approveRemark) {
    const data = {
        id,
        status,
        approveStatus,
        oldApproveStatus,
        approveRemark
    }
    return request({
        url: '/system/salesOrder/approve',
        method: 'post',
        data: data
    })
}

// 销售转采购审核/反审核
export function orderApproveConversion(id, status, approveStatus, oldApproveStatus, approveRemark, salesOrderDetailList) {
    const data = {
        id,
        status,
        approveStatus,
        oldApproveStatus,
        approveRemark,
        salesOrderDetailList
    }
    return request({
        url: '/system/salesOrder/approve',
        method: 'post',
        data: data
    })
}

// 根据sku查询
export function orderSearch() {
    return request({
        url: '/system/productBasicInformation/selectProductSpecifications',
        method: 'get'
    })
}

// 查询批次号
export function orderBatchNumber(id) {
    return request({
        url: '/system/productStore/list?productId=' + id,
        method: 'get'
    })
}

// 查询所有库存数据
export function getBatchNumber(warehouseId, specificationCode) {
    return request({
        url: '/system/productStorage/queryList?warehouseId=' + warehouseId + '&specificationCode=' + specificationCode,
        method: 'get'
    })
}

// 查询库存数量
export function orderSearchStorage(data) {
    return request({
        url: '/system/productStorage/queryStorage',
        method: 'get',
        params: data
    })
}

// 组织架构获取
export function deptTree(data) {
    return request({
        url: '/system/salesOrder/deptTree',
        method: 'get',
        params: data
    })
}

// 销售退货订单客户名称查询销售订单
export function querySalesOrder(data) {
    return request({
        url: '/system/salesReturnOrder/querySalesOrder',
        method: 'get',
        params: data
    })
}
